package org.dairy.farms.dao.hibernate;

import org.dairy.farms.dao.FeedTypeDAO;
import org.dairy.farms.dao.LivestockStatusTypeDAO;
import org.dairy.farms.dao.generic.AbstractDAOImpl;
import org.dairy.farms.model.FeedType;
import org.dairy.farms.model.LivestockStatusType;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: GDuggira
 * Date: 20 Oct, 2011
 * Time: 12:32:51 PM
 */
@Repository("livestockStatusTypeDao" )
public class LivestockStatusTypeDAOImpl  extends AbstractDAOImpl<LivestockStatusType,Long> implements LivestockStatusTypeDAO {
    @Override
    public LivestockStatusType findByName(String livestockStatusTypeName) {
        List<LivestockStatusType> livestockStatusTypeNameList = basePersistence.findByProperty(FeedType.class,"name",livestockStatusTypeName);
        if(livestockStatusTypeNameList != null && livestockStatusTypeNameList.size()>=1){
            return livestockStatusTypeNameList.get(0);
        }
        return null;
    }
}
